<?php
require("../global.php");
 //echo URL_PATH;
//header("Content-type: text/html;charset=GB2312");
$_SESSION["file_info"] = array();
//$location = URL_PATH."SwfUpload/myuploads/";
//echo $location;
		$sql="select * from dorderfilecfg where order_id='".$_REQUEST['order_id']."' and of_type='".$_REQUEST['uflag']."' order by of_time desc";
		
		//$qrfilear=$db->get_sql_arr($sql,'mysql_fetch_assoc');
		$total=$db->get_num_rows($sql); 
		
		if($total > 0)
		{
			$clist = 'selected';
			$cupload = 's12';
		}else{
			$clist = 's12';
			$cupload = 'selected';			
		}

	  $sqlup="select fs_flag,sr_name from srmenucode where fs_type='5' and fs_flag='".$_REQUEST['uflag']."' limit 1";
	  
	  $uparr=$db->get_sql_row($sqlup,'mysql_fetch_assoc');

      if($_REQUEST['isorder']){
	    $sqlorder = "SELECT customer_id,cus_name,tuanno FROM dordermsg WHERE order_id = ".$_REQUEST['order_id']." limit 1";
		$orderinfo=$db->get_sql_row($sqlorder,'mysql_fetch_assoc');
	  }else{
	    $orderinfo['customer_id'] = '';
		$orderinfo['cus_name'] = '';
		$orderinfo['tuanno'] = '';
	  }	 	  
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <title>附件上传</title>
        <link href="<?php echo URL_PATH;?>SwfUpload/css/swfupload.css" rel="stylesheet" type="text/css" />
        <link href="<?php echo URL_PATH;?>SwfUpload/css/idtabs.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="<?php echo URL_PATH;?>SwfUpload/js/swfupload/swfupload.js"></script>
        <script type="text/javascript" src="<?php echo URL_PATH;?>SwfUpload/js/swfupload/handlers.js"></script>
        <script type="text/javascript" src="<?php echo URL_PATH;?>SwfUpload/js/swfupload/fileprogress.js"></script>
        <script type="text/javascript" src="<?php echo URL_PATH;?>SwfUpload/js/jquery-1.3.2.min.js"></script>
        <script type="text/javascript" src="<?php echo URL_PATH;?>SwfUpload/js/jquery.idTabs.min.js"></script>
        <script type="text/javascript">
            var swfu;
            window.onload = function () {
                swfu = new SWFUpload({
                    // Backend Settings
                    upload_url:"<?php echo URL_PATH;?>SwfUpload/upload.php",
                    post_params: {"PHPSESSID": "<?php echo session_id(); ?>","order_id": "<?php echo $_REQUEST['order_id'];?>","upflag": "<?php echo $_REQUEST['uflag'];?>"},

                    // File Upload Settings
                    file_size_limit : "10 MB",	// 2MB
                    //file_types : "*.*",
                    //file_types_description : "JPG Images",
                    file_upload_limit : "0",

                    // Event Handler Settings - these functions as defined in Handlers.js
                    //  The handlers are not part of SWFUpload but are part of my website and control how
                    //  my website reacts to the SWFUpload events.
                    file_queued_handler : fileQueued,
                    file_queue_error_handler : fileQueueError,
                    file_dialog_complete_handler : fileDialogComplete,
                    upload_progress_handler : uploadProgress,
                    upload_error_handler : uploadError,
                    upload_success_handler : uploadSuccess,
                    upload_complete_handler : uploadComplete,

                    // Button Settings
                    button_image_url : "<?php echo URL_PATH;?>SwfUpload/images/swfupload/SmallSpyGlassWithTransperancy_17x18.png",
                    button_placeholder_id : "spanButtonPlaceholder",
                    button_width: 120,
                    button_height: 18,
                    button_text : '<span class="button">浏览<span class="btn_startupload">(最大 10 MB)</span></span>',
                    button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12px; }',
                    button_text_top_padding: 0,
                    button_text_left_padding: 18,
                    button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
                    button_cursor: SWFUpload.CURSOR.HAND,

                    // Flash Settings
                    flash_url : "<?php echo URL_PATH;?>SwfUpload/js/swfupload/swfupload.swf",

                    custom_settings : {
                        progressTarget : "fsUploadProgress",
                        cancelButtonId : "btnCancel"
                    },

                    // Debug Settings
                    debug: false
                });
            };

            $("document").ready(function(){
                $("#uploadpanel ul").idTabs();
            });

         function showuploadlist(orderid,uflag,fs_type)
         {
            	 $.ajax({
								type:'POST',
								url:'../public/showupload.php',
								data:'order_id='+orderid+'&uflag='+uflag+'&fs_type='+fs_type,
								beforeSend: function(){
								$('#slist').html("");
									tr = document.getElementById('slist').insertRow(-1);//行
									
									td = tr.insertCell(-1);//列
									td.colSpan = 2;
									td.className = 'acenter';
									var img = document.createElement('img');
									    img.src='../images/working.gif';
									   
									td.appendChild(img);
									td.appendChild(document.createTextNode("数据正在加载"));			   	 
				   	    },
								success:function(data){
								  $("#slist").html(data);
				        }		 
		 
	             });	
         }
         
         function deleteupload(orderid,uflag,of_id,doact)
         {
            
            
            if(confirm("您确定要删除吗？"))
						{
            	 $.ajax({
								type:'POST',
								url:'../public/showupload.php',
								data:'order_id='+orderid+'&uflag='+uflag+'&of_id='+of_id+'&doact='+doact,
								beforeSend: function(){
								$('#slist').html("");
									tr = document.getElementById('slist').insertRow(-1);//行
									//tr.className = 'fontlist';	
									
									td = tr.insertCell(-1);//列
									td.colSpan = 2;
									td.className = 'acenter';
									var img = document.createElement('img');
									    img.src='../images/working.gif';
									   
									td.appendChild(img);
									td.appendChild(document.createTextNode("数据正在加载"));			   	 
				   	    },
								success:function(data){
								  $("#slist").html(data);
				        }		 
		 
	             });	
						}
         }
        </script>
    </head>
    <body>
         <div id="uploadpanel" class="usual">
            <ul>
                <li>
                    <a class=<?php echo $cupload;?> href="#tab1">附件上传</a>
                </li>
                <li>
                    <a class=<?php echo $clist;?> href="#tab3" onclick="javascript:showuploadlist(<?php echo $_REQUEST['order_id'] ;?>,<?php echo $_REQUEST['uflag'];?>,'','show');">附件列表</a>
                </li>
            </ul>
            <div id="tab1" class="div">
                <div id="content">
                    <h2>【<?php echo mb_convert_encoding($orderinfo['customer_id'], "UTF-8", "GBK"),'--',mb_convert_encoding($orderinfo['cus_name'], "UTF-8", "GBK"),$orderinfo['tuanno'] .'&nbsp;&nbsp;';echo mb_convert_encoding($uparr['sr_name'], "UTF-8", "GBK");?>】</h2>
                    <p>可以同时上传多个，上传成功显示在附件列表</p>
                    <?php
                    if( !function_exists("imagecopyresampled") ) {
                        ?>
                    <div class="message">
                        <h4><strong>错误:</strong> </h4>
                        <p>服务器端并没有安装GD库</p>
                        <p>请在php.ini中把<code>;extension=php_gd2.dll</code>修改为<code>extension=php_gd2.dll</code> and making sure your extension_dir is pointing in the right place. <code>extension_dir = "c:\php\extensions"</code></p>
                    </div>
                        <?php
                    } else {
                        ?>
                    <form>
                        <div class="fieldset flash" id="fsUploadProgress">
                            <span class="legend">上传队列</span>
                        </div>
                        <div style="display: inline; border: solid 1px #7FAAFF; background-color: #C5D9FF; padding: 2px;">
                            <span id="spanButtonPlaceholder"></span>&nbsp;&nbsp;&nbsp;&nbsp;
                            
                        </div>
                        <input type="button" value="开始上传" class="btn_startupload" style="margin-left:10px;font-family: Helvetica, Arial, sans-serif; font-size: 18px;" onclick="swfu.startUpload();"/>
                    </form>
                        <?php
                    }
                    ?>
                    <!--<div id="thumbnails"></div>-->
                </div>
            </div>
            <div id="tab3" class="div">
            	<!----------------------------- 显示列表-----------------开始-->
								<table class="tableborder" width="80%" border="0" align="center" cellpadding="3" cellspacing="1">
									<tr>
										 <td colspan="2"><h2>【<?php  echo mb_convert_encoding($orderinfo['customer_id'], "UTF-8", "GBK"),'--',mb_convert_encoding($orderinfo['cus_name'], "UTF-8", "GBK"),$orderinfo['tuanno']  .'&nbsp;&nbsp;'; echo mb_convert_encoding($uparr['sr_name'], "UTF-8", "GBK");?>】</h2></td>
									</tr>
									<tbody id="slist">

								  </tbody>
								</table>
								<!----------------------------- 显示列表-----------------结束-->	            	
            </div>
        </div>
    </body>
</html>